import request from '@/utils/request'
import type { Article, ArticlePage, AueryType } from '@/api/types/article'

export const pageList = (params: AueryType) => {
  return request<ArticlePage>({
    method: 'get',
    url: '/admin/article/page',
    params
  })
}

export const add = (data: Article) => {
  return request<boolean>({
    method: 'post',
    url: '/admin/article',
    data
  })
}

export const update = (data: Article) => {
  return request<boolean>({
    method: 'put',
    url: '/admin/article',
    data
  })
}

export const getById = (id: number) => {
  return request<Article>({
    method: 'get',
    url: '/admin/article/' + id
  })
}

export const deleteByIds = (ids: number) => {
  return request<boolean>({
    method: 'delete',
    url: '/admin/article/' + String(ids)
  })
}

export const releaseByIds = (ids: number, status: string) => {
  return request<boolean>({
    method: 'put',
    url: '/admin/article/' + String(ids) + "/" + status
  })
}

export const updateComment = (data: Article) => {
  return request<boolean>({
    method: 'put',
    url: '/admin/article/comment/' + data.articleId + "/" + data.isComment
  })
}